<template>
    <section class="jumbotron">
      <h3 class="jumbotron-heading">Search Github Users</h3>
      <div>
        <input type="text" placeholder="enter the name you search" v-model="keyword"/>
        <button @click="getUsers">Search</button>
      </div>
    </section>
</template>

<script>
    import axios from 'axios'
    export default {
        name: 'SSearch',
        data() {
            return {
                keyword: ''
            };
        },
        methods: {
            getUsers() {
                axios.get(`https://api.github.com/search/users?q=${this.keyword}`)
                    .then(response => {
                        console.log(response.data.items)
                        this.$bus.$emit('updateListData', response.data.items)
                    })
                    .catch(error => {
                        console.log(error)
                    })
            }
        }
    };
</script>
